<template>
    <view class="u-demo-block">
        <view class="addressView">
            <view class="av-1">{{mailDefault.address}}</view>
            <view class="av-2">
                <span class="av-span1">{{mailDefault.addressee}}</span>
                <span class="av-span2">{{mailDefault.phone}}</span>
            </view>
        </view>


        <view class="swipe-action u-border-top u-border-bottom" v-for="(cart,index) in cartDto">
            <view class="swipe-action__content">
                <view>
                    <img :src="cart.picUrl" style="width: 100px">
                </view>
                <view>
                    <p>{{cart.spuName}}</p>
                    <p style="color: #B2B2B2;font-size: 9px">{{cart.skuName}}</p>
                </view>
                <view>
                    <span>￥{{cart.price}}</span>
                </view>
                <view>
                    数量: {{cart.amount}}
                </view>
            </view>
        </view >
        <view class="fixedView">
            <view>￥{{totalPrice}}</view>
            <button @click="createGoodsOrder">去支付</button>
        </view>
    </view>
</template>
<script>
    import Request from '../../utils/request'
    export default {
        data() {
            return{
                totalPrice:'',
                mailDefault:{

                },
                cart:"",
                userId:1,
                cartDto:[],
                cartNumber:'',
                mailId:''
            }
        },
        created(){
            //this.getMailDefault()
            this.cartNumber=uni.getStorageSync("cartNumber")
            //alert(this.cartNumber)
            this.waitPay()
        },
        methods:{
            /*跳转页面*/
            goPage(url){
                uni.navigateTo({
                    url: url
                });
            },
            /*获取下单地址*/
            getMailDefault(){
                Request.request('management-mall/leyou.order/order-mail/getMailById'
                    , {mailId: this.mailId}, 'post').then(res => {
                    console.log(res)
                    // console.log(res.data.specsList)
                    this.mailDefault=res.data.one
                }).catch(error => {
                    console.error(error)
                })
            },
            /*根据购物车number回显*/
            waitPay(){
                Request.request('management-mall/leyou.order/order-goods/waitPay'
                    ,{"cartNumber":this.cartNumber},'post').then(res=>{
                    console.log(res)
                    this.cartDto=res.data.list
                    this.totalPrice=res.data.totalPrice
                    this.mailId=res.data.mailId
                    this.getMailDefault()
                }).catch(error=>{
                    console.error(error)
                })
            },
            /*下单*/
            createGoodsOrder(){

                uni.setStorageSync("orders",this.cartNumber)
                uni.navigateTo({
                    url: '/pages/sjh/payment'
                });

            }
        }
    }
</script>

<style>
    .addressView{
        background: #e1f3d8;
        padding: 10px;
        margin: 5px;
    }
    .av-1{

    }
    .av-2{
        color: #B2B2B2;
    }
    .av-span1{
        margin-right: 20px;
    }
    .av-span2{

    }
    .fixedView{
        width: 100%;
        padding: 15px 10px;
        position: fixed;
        bottom: 0;
        background: #e1f3d8;
    }
    .fixedView>view{
        padding-top: 10px;
        float: left;
    }
    .fixedView>button{
        float: right;
        margin-right: 35px;
    }
    .swipe-action__content>view{
        margin-left: 10px;
    }
</style>
